package com.example.love_margin.Mapper;


import com.example.love_margin.Entity.Organization;
import com.example.love_margin.Mapper.configuer.DeleteMany;
import com.example.love_margin.Mapper.configuer.SeletPetPicture;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrganizationMapper {

    @Insert("INSERT INTO organization(organization_name,organization_contact,organization_wechat,organization_area,organization_big_area,organization_message,organization_picture)" +
            "values(#{organization_name},#{organization_contact},#{organization_wechat},#{organization_area}," +
            "#{organization_big_area},#{organization_message},#{organization_picture})")
    int addOr(Organization organization);

    @Delete("DELETE FROM organization WHERE organization_id=#{organization_id}")
    int deleteOr(int organization_id);
    //批量删除

    @DeleteProvider(type = DeleteMany.class,method = "deleteM")
    int deleteOrs(String sql);

    //查询多个对象的图片的地址用以删除
    @SelectProvider(type = SeletPetPicture.class,method = "SelectPetP")
    List<String> selectPetAll(String URL);

    @Select("SELECT * FROM organization WHERE organization_id = #{organization_id}")
    Organization selectOne(int organization_id);

    @Select("SELECT * FROM organization")
    List<Organization> selectMany();
    @Update("UPDATE organization SET organization_name=#{organization_name},organization_contact=#{organization_contact},organization_wechat=#{organization_wechat}," +
            "organization_area=#{organization_area},organization_picture=#{organization_picture}" +
            "organization_big_area=#{organization_big_area},organization_message=#{organization_message} " +
            "WHERE organization_id = #{organization_id}")
    int updateOr(Organization organization);

}
